API Documentation
Public Member Functions | List of all members
nkMemory::BitStream Class Reference

Offers capabilities to read data bit per bit. More...

Public Member Functions

 BitStream (BufferView<> data)
 
 ~BitStream ()
 
BufferView getData () const
 
unsigned char getCurrentByte () const
 
unsigned int getByteCounter () const
 
unsigned int getBitCounter () const
 
unsigned int peekMsb (unsigned int count)
 
unsigned int peekLsb (unsigned int count)
 
unsigned int readMsb (unsigned int count)
 
unsigned int readLsb (unsigned int count)
 
void moveForward (unsigned int count)
 

Detailed Description

Offers capabilities to read data bit per bit.

Constructor & Destructor Documentation

◆ BitStream()

nkMemory::BitStream::BitStream ( BufferView<>  data)

Constructor.

Parameters
dataThe data buffer to work on.

◆ ~BitStream()

nkMemory::BitStream::~BitStream ( )

Destructor.

Member Function Documentation

◆ getData()

BufferView nkMemory::BitStream::getData ( ) const
Returns
The data used by the stream.

◆ getCurrentByte()

unsigned char nkMemory::BitStream::getCurrentByte ( ) const
Returns
The current byte within the buffer. Shorthand for indexing the data using the current byte counter.

◆ getByteCounter()

unsigned int nkMemory::BitStream::getByteCounter ( ) const
Returns
The current byte counter, which corresponds to the byte index the stream is currently on.

◆ getBitCounter()

unsigned int nkMemory::BitStream::getBitCounter ( ) const
Returns
The current bit counter, which corresponds to the bit index, within the current byte, the stream is currently on.
Remarks
This index can ultimately point to a different position depending on the stream's endianness.

◆ peekMsb()

unsigned int nkMemory::BitStream::peekMsb ( unsigned int  count)

Peeks bits from the position the stream is currently on, for a Most-Significant-Byte first layout. The stream does not moves forward during this operation.

Parameters
countThe number of bits to read.
Returns
The result of the reading.
Remarks
Both the bytes, and bits, are considered MSB (as a result, read from left to right).

◆ peekLsb()

unsigned int nkMemory::BitStream::peekLsb ( unsigned int  count)

Peeks bits from the position the stream is currently on, for a Least-Significant-Byte first layout. The stream does not moves forward during this operation.

Parameters
countThe number of bits to read.
Returns
The result of the reading.
Remarks
Both the bytes, and bits, are considered LSB (as a result, read from right to left).

◆ readMsb()

unsigned int nkMemory::BitStream::readMsb ( unsigned int  count)

Read bits, moving the stream forward, for a Most-Significant-Byte first layout.

Parameters
countThe number of bits to read.
Returns
The result of the reading.

◆ readLsb()

unsigned int nkMemory::BitStream::readLsb ( unsigned int  count)

Read bits, moving the stream forward, for a Least-Significant-Byte first layout.

Parameters
countThe number of bits to read.
Returns
The result of the reading.

◆ moveForward()

void nkMemory::BitStream::moveForward ( unsigned int  count)

Move the stream forward.

Parameters
countThe number of bits to move forward.

The documentation for this class was generated from the following file: